#pragma once
#ifndef SERVICELOCATOR_H_
#define SERVICELOCATOR_H_

#include <stdio.h>

class ServiceLocator
{
public:
	enum eServices
	{
		eServ_Invalid,
		eServ_First = 1,
		eServ_Renderer = eServ_First,
		eServ_Input,
		eServ_Max
	};
public:
	template <class T> static void RegisterService( T* service );
	template <class T> static T* GetService();

private: 
	static void* m_services[eServ_Max]; 
};

template <class T> void ServiceLocator::RegisterService( T* service )
{
	m_services[(int)T::GetType()] = service;
}

template <class T> T* ServiceLocator::GetService()
{
	return static_cast<T*>(m_services[(int)T::GetType()]);
}



template <class T> class Service
{
public:
	Service( T* obj );
};

template <class T> Service<T>::Service( T* obj )
{
	ServiceLocator::RegisterService<T>(obj);
}

#define DECLARE_SERVICE(className, serviceEnum, stringName) \
						public: \
						static ServiceLocator::eServices GetType() { return serviceEnum; }\
						virtual const char* GetName() { return stringName; }\
// 						private: \
// 						void ServiceInit();






#endif//SERVICELOCATOR_H_

